package beanstao.util.type.base;

import java.util.regex.Pattern;

import beanstao.util.exception.technical.util.reflect.FailToCastObjectException;
import beanstao.util.type.Castor;

public class String2Pattern extends Castor<String, Pattern>
{

	@Override
	public Pattern cast(String src, Class<?> toType, String... args) throws FailToCastObjectException
	{
		try
		{
			return Pattern.compile(src);
		}
		catch (Exception e)
		{
			throw new FailToCastObjectException("Error regex: " + src);
		}
	}

}
